/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package shellCommands;

import Sessions.EcomAdminRemote;
import Sessions.EcomCustomersRemote;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author SOGOBA
 */
public class ConnectCommand implements InterShell {
    ContextCommande cxtCmd;
   
    @Override
    public Commands getName() {
        return Commands.connect;
    }

    public ConnectCommand (ContextCommande ContextCommand){
          cxtCmd =  ContextCommand;
    }

    @Override
    public String getShortDescription() {
        return "connect client to the system \n";

    }

    @Override
    public void execute(String cmd,EcomAdminRemote ecomAdmin,EcomCustomersRemote ecomCust) throws Exception {
            StringTokenizer st = new StringTokenizer(cmd, " ");
            // Ignore la commande
            st.nextToken();
            // sans argument, on liste les produits du caddie en cours
            if (st.countTokens() == 2) {
                String name = st.nextToken();
                String pwd= st.nextToken();
                ecomCust.getConnect(name, pwd);
     //           cxtCmd.setVar("state", true);
                System.out.println("You are now connect to the system");
            }
        }
           
}


